﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;

namespace WeatherHistory.Api.Controllers;

/// <inheritdoc />
[ApiController]
[Produces("application/json")]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
public abstract class ApiControllerBase : ControllerBase
{
    private IMediator? _mediator;
    /// <summary>
    ///     Инстанс медиатора в контексте текущего HTTP запроса
    /// </summary>
    protected IMediator Mediator => _mediator ??= HttpContext.RequestServices.GetService<IMediator>()!;
}